package com.springboot.jdk.atomic;

import java.util.concurrent.atomic.AtomicStampedReference;

/**
 * @author: zr
 * @date: 2021-09-27
 */
public class AtomicStampedReferenceDemo {

    private static int count = 0;
    private static AtomicStampedReference<Integer> num = new AtomicStampedReference(0, 0);

    public static void main(String[] args) {
        Integer expectedReference = num.getReference();
        int expectedStamp = num.getStamp();
        num.compareAndSet(expectedReference, 1, expectedStamp, 3);
        System.out.println(num.getReference());
        System.out.println(num.getStamp());

        num.compareAndSet(1, 5, 3, 8);
        System.out.println(num.getReference());
        System.out.println(num.getStamp());
    }
}
